package com.prd.controller;


import com.prd.dto.SysStaticMenuDTO;
import com.prd.service.SysStaticMenuService;
import com.prd.util.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lizhaoyi
 * @since 2024-01-21
 */
@RestController
@RequestMapping("/api/sysStaticMenuDO")
@Api(tags = "静态菜单页面管理")
public class SysStaticMenuController {


    @Autowired
    private SysStaticMenuService staticMenuService;

    @ApiOperation("获取菜单列表")
    @GetMapping
    public JsonData getAllList(){

        return staticMenuService.getAllList();
    }

    @ApiOperation("根据用户id获取菜单列表")
    @GetMapping("/getListByUserId/{userId}")
    public JsonData getListByUserId(@PathVariable Long userId){

        return staticMenuService.getListByUserId(userId);
    }

    @ApiOperation("根据用户id获取顶级菜单列表")
    @GetMapping("/getTopListByUserId/{userId}")
    public JsonData getTopListByUserId(@PathVariable Long userId){

        return staticMenuService.getTopListByUserId(userId);
    }


    @ApiOperation("获取当前用户菜单列表")
    @GetMapping("/getList")
    public JsonData getList(){

        return staticMenuService.getList();
    }

    @ApiOperation("获取当前用户顶级菜单列表")
    @GetMapping("/getTopList")
    public JsonData getTopList(){

        return staticMenuService.getTopList();
    }

    @ApiOperation("根据角色id获取当前用户菜单列表")
    @GetMapping("/getListByRoleId/{roleId}")
    public JsonData getListByRoleId(@PathVariable Long roleId){

        return staticMenuService.getListByRoleId(roleId);
    }

    @ApiOperation("根据角色id获取当前用户顶级菜单")
    @GetMapping("/getTopListByRoleId/{roleId}")
    public JsonData getTopListByRoleId(@PathVariable String roleId){

        return staticMenuService.getTopListByRoleId(roleId);
    }

    @ApiOperation("保存菜单列表")
    @PostMapping
    public JsonData saveMenus(@RequestBody @Validated List<SysStaticMenuDTO> menuDTOs){

        return staticMenuService.saveMenus(menuDTOs);
    }

}

